package model.semantics.unary;

import model.semantics.UnaryOperation;



/**
 * Clamp results to [-1, 1].
 * 
 * @author Anne Weng
 */
public class Clamp extends UnaryOperation
{
	protected boolean leftAssociative = false;
	
	public Clamp(int precedence)
	{
		super(precedence);
	}
	
    @Override
    protected double evaluateValue (double value)
    {
        if (value < -1)
        	return -1;
        else if (value > 1)
        	return 1;
        else
        	return value;
    }
}
